﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DemoTypedDataSet : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Lấy dữ liệu
        Northwind northwindDataSet = new Northwind();
        Northwind.ProductsDataTable products = northwindDataSet.Products;
        NorthwindTableAdapters.ProductsTableAdapter productsTableAdapter = new NorthwindTableAdapters.ProductsTableAdapter();

        productsTableAdapter.Fill(products);
        
        // Thêm dòng
        Northwind.ProductsRow row = products.NewProductsRow();
        row.ProductName = "Tên dòng mới";

        products.AddProductsRow(row);

        // Edit dòng số 0
        Northwind.ProductsRow editedRow = products[0];

        editedRow.ProductName = "Tên mới";

        productsTableAdapter.Update(products);
        
        // Xóa dòng số 0
        Northwind.ProductsRow deletedRow = products[0];

        deletedRow.Delete();

        productsTableAdapter.Update(products);
    }
}